[PageLifecycle] Add WPT test for lifecycle's onfreeze callback Since the onfreeze callback is invoked based on an internal decision from the browser, to be able to test the callback, we are adding support for it from chromeGPUBenchmak as well as in chromedriver/WebDriver. This CL focuses on the chromeGPUBenchmark solution. The WPT test itself, verifies that the onfreeze callback is called, and it also verifies that only fetch keepalive is allowed from withing the callback. Bug: chromium:837709 Change-Id: Ia4cb16dc10625f478ec270617da1a26395a9d29d Reviewed-on: https://chromium-review.googlesource.com/1072899 Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org> Reviewed-by: Shubhie Panicker <panicker@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Fadi Meawad <fmeawad@chromium.org> Cr-Commit-Position: refs/heads/master@{#563338} diff --git a/lifecycle/freeze.html b/lifecycle/freeze.html new file mode 100644 index 0000000..66bbbff --- /dev/null +++ b/lifecycle/freeze.html
@@ -0,0 +1,48 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>TestDriver freeze method</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +var test = async_test('Test freeze callback.'); +var childWindow = window.open('resources/window.html', 'Child Window'); +var total_steps = 0; + +const StepStatus = { + ADDED: 0, + SUCCESS: 1, + FAIL: 2, +}; + +var steps_map = new Map(); + +function add_step(name) { + steps_map[name] = StepStatus.ADDED; + total_steps++; +} + +function step_success(name) { + total_steps--; + steps_map[name] = StepStatus.SUCCESS; + if (total_steps == 0) + test.done(); +} + +function step_fail(name) { + total_steps--; + steps_map[name] = StepStatus.FAIL; + test.step(() => assert_unreached('During onfreeze: ' + name + ' failed to behave as expected.')); + if (total_steps == 0) + test.done(); +} + +test.step_timeout(() => { + for (var step in steps_map) { + if(steps_map[step] == StepStatus.ADDED) + test.step(() => assert_unreached('During onfreeze: ' + step + ' never finshed.')); + } +}, 1000); + +</script> +